<?php
/**
 * Index page
 * 
 *     SCMwiki Copyright (C) 2010  Callan Bryant <callan1990@googlemail.com>
 *     
 *     Based on Voswork - A simple, fast PHP filesystem abstraction layer
 *     Voswork Copyright (C) 2010  Callan Bryant <callan1990@googlemail.com>
 * 
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY. without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * 
 * @package main
 * @author Callan Bryant <callan1990@googlemail.com>
 */

/** 
 * The object created represents the HTML based index
 * 
 * @author Callan Bryant
 */
class indexPage extends template
{
	protected $paths;

	public function __construct($paths)
	{
		$this->paths = $paths;
		natcasesort($this->paths);
	
		$time = time();
		$this->title = 'Index';
		$this->description = count($this->paths).' wiki pages';

		$this->article = '<p><table><tr> <th>Page name</th> <th>Summary</th>'.
		'<th>Last updated</th></tr>';

		foreach ($this->paths as $path)
		{
			$article = scmwikiCrawler::get_article($path);

			$this->article .= '<tr><td><a href="'.parser::PAGE_LINK_PREFIX.$article->name.'">'.$article->name.'</a></td>'.
			'<td>'.$article->summary.'</td>'.
			'<td>'.template::evaluate_seconds($time-$article->modified).' ago</td> </tr>';
		}

		$this->article .= '</table></p>';
		$this->note = 'Create "Home" to override this page';
		$this->comment = kernel::elapsed().'ms';
	}
}
?>
